package Controller;


import java.io.IOException;
import java.util.ArrayList;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


import DAO.DAOFactory;
import DAO.HolidayDAO;
import Model.*;

/**
 * Servlet implementation class HolidayList
 */
@WebServlet("/HolidayList")
public class HolidayList extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public HolidayList() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doProcess(request,response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doProcess(request,response);
	}
protected void doProcess(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
	HolidayDAO holidayDAO=DAOFactory.getInstance().getHolidayDAO();
	ArrayList<HolidayBean> holidayList=new ArrayList<HolidayBean>();
	try{
		holidayList=holidayDAO.findAllHoliday();
	}catch(Exception e){
		e.printStackTrace();
	}
	request.setAttribute("HolidayList", holidayList);
	RequestDispatcher rd=request.getRequestDispatcher("HolidayList.jsp");
	rd.forward(request,response);
	
}
}
